package com.wdh.dbutil.ykzx;

import java.util.HashSet;
import java.util.Set;

import org.apache.commons.pool2.impl.GenericObjectPoolConfig;
import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

public class RedisTest {

    public static void main(String[] args)throws Exception {
        String hostAndPorts = "redis-0.redis-hs.qa-fgw.svc.cluster.local:6379,redis-1.redis-hs.qa-fgw.svc.cluster.local:6379,redis-2.redis-hs.qa-fgw.svc.cluster.local:6379";

/*
        JedisPoolConfig config = new JedisPoolConfig();
        config.setMaxTotal(20);
        config.setMaxIdle(20);
        config.setBlockWhenExhausted(false);
        config.setMaxWaitMillis(20000);
        config.setTestOnBorrow(true);
        config.setTestOnReturn(true);
        config.setTestWhileIdle(true);
        config.setTimeBetweenEvictionRunsMillis(10000L);
        config.setMinEvictableIdleTimeMillis(30000L);
*/

        Set<HostAndPort> hostAndPortSet = new HashSet();
        String[] split = hostAndPorts.split(",");
        for (String s : split) {
            String[] arr = s.split(":");
            hostAndPortSet.add(new HostAndPort(arr[0], Integer.parseInt(arr[1])));
        }
        System.out.println("=============redis query start==================");
        JedisCluster jedisCluster = new JedisCluster(hostAndPortSet, 2000, 2000, 5, new GenericObjectPoolConfig());
        String rs = jedisCluster.get("RCUVEHCROSSSEQ:晋AF89787:U-BD00E2:20240426");
        System.out.println("------------");
        System.out.println(rs);
    }
}
